package com.example.winner.recyclerview;

import android.os.Bundle;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.DividerItemDecoration;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;

import java.util.ArrayList;
import java.util.List;

public class MainActivity extends AppCompatActivity {
    private List<ImageText> imagetextList=new ArrayList<>();

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        init();
        android.support.v7.widget.RecyclerView recyclerView= (RecyclerView) findViewById(R.id.recycle);
        LinearLayoutManager layoutManager=new LinearLayoutManager(this);
        //layoutManager.setOrientation(LinearLayoutManager.HORIZONTAL);
        //GridLayoutManager layoutManager=new GridLayoutManager(this,3);
        recyclerView.addItemDecoration(new DividerItemDecoration(this, DividerItemDecoration.VERTICAL));
        recyclerView.setLayoutManager(layoutManager);
        Adapter adapter=new Adapter(imagetextList);
        recyclerView.setAdapter (adapter);
    }
    private void init(){
        for(int i=0;i<5;i++) {
            ImageText a = new ImageText ( "aaa", R.mipmap.ic_launcher );
            imagetextList.add ( a );
            ImageText b = new ImageText ( "bbb", R.mipmap.ic_launcher );
            imagetextList.add ( b );
            ImageText c = new ImageText ( "ccc", R.mipmap.ic_launcher );
            imagetextList.add ( c );
            ImageText d = new ImageText ( "ddd", R.mipmap.ic_launcher );
            imagetextList.add ( d );
            ImageText e = new ImageText ( "eee", R.mipmap.ic_launcher );
            imagetextList.add ( e );
            ImageText f = new ImageText ( "fff", R.mipmap.ic_launcher );
            imagetextList.add ( f );
        }
    }
}
